package cn.gdcp.listviewtestbaseadapter;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class EditActivity extends AppCompatActivity {
    Button button;
    EditText nameEdit;
    EditText ageEdit;
    RadioButton radiom1;
    RadioButton radiom2;
    RadioButton radiom3;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);
        initEditView();

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String name=nameEdit.getText().toString();
                String age=ageEdit.getText().toString();
                int imgId=0;
                if(radiom1.isChecked())
                {  imgId=R.drawable.m1;}
                else if(radiom2.isChecked()){
                    imgId=R.drawable.m2;
                }
                else if(radiom3.isChecked()){
                    imgId=R.drawable.m3;
                }

                Intent intent=new Intent();
                intent.putExtra("AGE",age);
                intent.putExtra("NAME",name);
                intent.putExtra("IMGID",imgId);
                setResult(2,intent);
                finish();
            }
        });
    }

    private void initEditView() {
        button=(Button)findViewById(R.id.submit_edit);
        nameEdit=findViewById(R.id.edit_name);
        ageEdit=findViewById(R.id.edit_age);
        radiom1=findViewById(R.id.m1_edit);
        radiom2=findViewById(R.id.m2e_edit);
        radiom3=findViewById(R.id.m3e_eidt);
    }
}

